package cn.itcast.consumer.client;

import cn.itcast.consumer.pojo.User;
import feign.hystrix.FallbackFactory;

/**
 * @author 虎哥
 */
//@Component
public class UserClientFallback implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserClient() {
            @Override
            public User queryUserById(Long userId) {
                System.out.println(throwable.getMessage());
                User user = new User();
                user.setId(userId);
                user.setName("用户查询出现异常！");
                return user;
            }
        };
    }
}
